export const regExp = {
  name: (min = 2, max = 32) => ({
    reg: `^[a-zA-Z0-9_\u4e00-\u9fa5]{${min},${max}}$`,
    text: `${min}-${max}个字符，支持中文、英文字母、数字和下划线`,
  }),
  nameCN: (min = 1, max = 32) => ({
    reg: `^[0-9_\u4e00-\u9fa5]{${min},${max}}$`,
    text: `${min}-${max}支持中文、数字和下划线`,
  }),
  configname: (min = 1, max = 16) => ({
    reg: `^[a-zA-Z0-9\u4e00-\u9fa5]{${min},${max}}$`,
    text: `${min}-${max}个字符，支持中文、英文字母、数字`,
  }),
  config: (min = 1, max = 16) => ({
    reg: `^[a-zA-Z0-9]{${min},${max}}$`,
    text: `${min}-${max}个字符，支持英文字母和数字`,
  }),
  characteristic: (min = 1, max = 16) => ({
    reg: `^[a-zA-Z0-9_]{${min},${max}}$`,
    text: `${min}-${max}个字符，支持英文字母、数字和下划线`,
  }),
  functionName: (min = 1, max = 32) => ({
    reg: `^[a-zA-Z][a-zA-Z0-9_\u4e00-\u9fa5]{${min - 1},${max - 1}}$`,
    text: `${min}-${max}个字符，支持英文字母、数字和下划线，并以英文字母开头`,
  }),
  proName: (min = 2, max = 32) => ({
    reg: `^[\\w\\s\\S]{${min},${max}}$`,
    text: `${min}-${max}个字符`,
  }),
  password: (min = 6, max = 32) => ({
    reg: `^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{${min},${max}}$`,
    text: `${min}-${max}个字符，必须包含大小写字母、数字和特殊字符`,
  }),
  phone: () => ({
    reg: /^1\d{10}$/,
    text: '手机号格式错误',
  }),
  port: () => ({
    reg: /^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/,
    text: '请输入有效的端口号，0-65535之间',
  }),
  email: () => ({
    reg: /^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@[a-zA-Z0-9]+((\.[a-z0-9A-Z]{1,})+)$/,
    text: '请输入正确的邮箱',
  }),
  url: () => ({
    reg: /(https?|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/,
    text: '请输入正确的url',
  }),
  path: () => ({
    reg: /^\/[a-zA-Z0-9/-]+$/,
    text: '路径支持字母、数字、正斜杠和连字符(-)，且只能/开头',
  }),
}
